package cn.wolfcode.p2p.base.domain;

import java.util.Date;
import java.util.HashMap;

import cn.wolfcode.p2p.base.util.DateUtil;
import cn.wolfcode.p2p.base.util.JSONUtil;
import cn.wolfcode.p2p.base.util.MaskUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 *    
 *    
 *    @author 
 *    @since 2018-11-26 15:02:35
 */
@Getter
@Setter
@Accessors(chain = true)
public class RealAuth extends AuthBaseDomain {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	// 性别常量
    public static final Integer SEX_MAN = 0; // 男
    public static final Integer SEX_WOMAN= 1; // 女


    /**
     * 身份证号码
     */
    private String idNumber;

    /**
     * 真实姓名
     */
    private String realName;

    /**
     * 性别
     */
    private Integer sex = SEX_MAN;

    /**
     *  出生年月
     */
    private Date bornDate;

    /**
     * 户口所在地
     */
    private String address;


    /**
     * 身份证正面图片地址
     */
    private String image1;

    /**
     * 身份证反面图片地址
     */
    private String image2;


    /**
     * 真实姓名打码
     * @return
     */
    public String getAnonymousRealName(){

        return MaskUtil.getAnonymousRealName(this.realName);
    }

    public String getAnonymousIdNumber(){
        return MaskUtil.getAnonymousIdNumber(this.getIdNumber());
    }

    public String getDisplaySex(){
        String displaySex = "男";
        if (sex == SEX_WOMAN){
            displaySex = "女";
        }
        return displaySex;
    }
    /**
     * 获取用户住址的隐藏字符串
     */
    public String getAnonymousAddress() {
        return MaskUtil.getAnonymousAddress(address);
    }


    // jsonString
    public String getJsonString(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("state", state);
        map.put("applierName", applier.getUsername());
        map.put("realName", realName);
        map.put("idNumber", idNumber);
        map.put("sex", sex == SEX_MAN ? "男" : "女");
        map.put("bornDate", DateUtil.getDateFormat(bornDate));
        map.put("address", address);
        map.put("image1", image1);
        map.put("image2", image2);
        map.put("remark", remark);

        return JSONUtil.toJSONString(map);

    }


}